import  cv2
import numpy as np
# img = cv2.imread('D:/mv1.png')
#图像缩放
# print(img.shape)#(512, 512, 3)
# face1 = img[220:400, 250:350]
# print(face1.shape)#(180, 100, 3)  高180 宽 100
# resized_face1 = cv2.resize(face1, (100, 180))#图像的缩放,指定图像大小
# print(resized_face1.shape) #(200, 110, 3)
# img[220:400, 250:350]=resized_face1
# #resimg=cv2.resize(img,None,fx=2,fy=1)#图像的缩放,指定缩放因子
# #cv2.imshow('resize',resimg)
# cv2.waitKey(0)
# print(img)
# cv2.imshow('old',img)
# print('-'*40)
# print(img[:,:,2])
# print('*'*40)
# print(img[:,:,1])
# print('='*40)
# print(img[:,:,0])
# print('#'*40)
# cv2.waitKey(0)
#---------------------------------------------------
# print(img.shape)#(512, 512, 3)
# print(img.shape[2])#3
# print(img.shape[:2])
#创建一个和原图像大小一致图像
# zeros = np.zeros(img.shape[:2], dtype=np.uint8)
# 拆分通道
# b,g,r = cv2.split(img)
# cv2.imshow('bbb',b)
# print(b.shape)
# print(b)
# print('-'*40)
#merge 通道合并
# b_img=cv2.merge([zeros, zeros, r])
# b_img=cv2.merge([b, zeros, zeros])
# print(b_img.shape)
# cv2.imshow('b_img',b_img)
# print(b_img)
# cv2.waitKey(0)
#---------------------------------------------------
# zeros1 = np.zeros((512,512), dtype=np.uint8)
# cv2.imshow('b_img1',zeros1)
# print(zeros1)
#---------------------------------------------------
#色彩变化，修改不同通道颜色
# zeros2 = np.zeros((512,512,3), dtype=np.uint8)
# cv2.imshow('b_img2',zeros2)
# print(zeros2)
# zeros2[:,:,0]=200
# zeros2[:,:,1]=100
# zeros2[:,:,2]=255 #红色
# cv2.imshow('b_img3',zeros2)
# print('-'*40)
# print(zeros2)
# cv2.waitKey(0)
#---------------------------------------------------
#修改局部部分图像像素点
# img = np.zeros((300,300,3),dtype=np.uint8)
# # img[:,0:100,0] = 255  # 第一列的蓝色通道设为255
# # img[:,100:200,1] = 255  # 第二列的绿色通道设为255
# img[:,100:300,2] = 255  # 第三列的红色通道设为255
# print(img)
# print('*'*40)
# # print(img[0,3])  # 打印出第一行第四列的像素值
# print(img[1,2,2])  # 打印出第二行第三列的蓝色通道值
# # img[0,3] = 255  # 将第一行第四列的像素值设为255
#
# cv2.imshow('img',img)
# cv2.waitKey(0)

# 创建一个2x4的三通道黑色图像
# zeros3 = np.zeros((100,100,3),dtype=np.uint8)
# zeros3[:,:,2]=255
# cv2.imshow('zeros3',zeros3)
# cv2.waitKey(0)
# print(img[0,3])  # 打印出第一行第四列的像素值
# img[1,2,2]=100
# print(img)
# print(img[1,2,2])  # 打印出第二行第三列的蓝色通道值
# img[0,3] = 255  # 将第一行第四列的像素值设为255
# print(img)  # 打印修改后的图像数组
# img[0,0] = [66,77,88]  # 将第一行第一列的像素值设为[66,77,88]
# print(img)  # 打印修改后的图像数组
# img[1,1,1] = 3  # 将第二行第二列的绿色通道值设为3
# print(img)  # 打印修改后的图像数组


import  cv2
import numpy as np
zeros3 = np.zeros((4,4,3),dtype=np.uint8)
zeros3[:,:,2]=255
#cv2.namedWindow('zeros3', cv2.WINDOW_NORMAL)
cv2.imshow('zeros3',zeros3)
cv2.waitKey(0)
cv2.destroyAllWindows()